<?php
Core::inc('modules/area/area.class.php');
Core::inc('modules/article/article.class.php');

function rpc_article_save()
{
	$id = Url::getVar('id');
	
	if ($id === null) {
		Event::log('modules.article', 'Can\'t save, no ID given', Event::LOG_ERROR);
	}
	
	$content = Url::getVar('content', '');
	
	Article::save(array('id' => $id, 'content' => $content));
	
	Ajax::$data['success'] = true;
	Ajax::$data['content'] = $content;
}

function rpc_article_create()
{
	$area = Url::getVar('area');
	
	if ($area === null) {
		Event::log('modules.article', 'Can\'t create new article, no areaID given', Event::LOG_ERROR);
	}
	
	$article = Article::create($area);
	
	Ajax::$data['success'] = true;
	Ajax::$data['id'] = $article['id'];
	Ajax::$data['content'] = $article['content'];
}

function rpc_article_delete()
{
	$id = Url::getVar('id');
	
	if ($id === null) {
		Event::log('modules.article', 'Can\'t delete, no ID given', Event::LOG_ERROR);
	}
	
	Article::delete($id);
	
	Ajax::$data['success'] = true;
}
?>